package com.xiaoma.tpo.dao;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.User;
import com.xiaoma.tpo.domain.UserFollow;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Owner on 2015/4/13.
 */
@Repository
public class UserFollowDao extends BaseDaoImpl<UserFollow> {
    public List<User> getMyFollows(int userid){
        String sql = "select a.* from user as a left join user_follow as b on a.id=b.follow_user_id where b.user_id=?";
        List<?> list = jdbcTemplate.query(sql, new DefaultRowMapper(User.class, getNameHandler()), userid);
        return (List<User>)list;
    }


    public void removeFollow(int userId,int followUserId){
        String sql = "delete from user_follow where user_id="+userId+" and user_follow_id="+followUserId;
        jdbcTemplate.execute(sql);
    }
}
